package com.cyh.ebptasywar.scheduler;

import com.cyh.ebptasywar.common.SchedulerFactory;
import com.cyh.ebptasywar.common.config.JobDetailConfig;
import com.cyh.ebptasywar.job.PromptWorkJob;
import com.cyh.ebptasywar.trigger.PromtWorkTrigger;
import com.cyh.ebptpubjar.ebptlogger.EbptLogger;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Scheduler来调度Trigger和JobDetil
 * JobDetail来实例化Job类并可以传值
 * @author theone
 */
@Component
@Scope("Singleton")
public class PromptWorkScheduler extends BaseScheduler{

    /**
     * scheduler工厂类
     */
    @Autowired
    private SchedulerFactory schedulerFactory;



    /**
     * 创建PromtWorkSchedulerS
     * @return
     * @throws SchedulerException
     */
    public Scheduler startPromtWorkScheduler() throws SchedulerException {
        EbptLogger.info(getClass(),"开始创建新的PromtWorkScheduler");
        List<Scheduler> schedulers =  schedulerFactory.createPromptWorkSchedulerFactory();
        for(Scheduler scheduler:schedulers){
            scheduler.start();
        }
        return null;
    }

}